stage.set_background("underwater")
score = 0
score_board = codesters.Display(score)
weak_pws = ["password", "password123", "hello1", "snuffles", "123456"]
strong_pws = ["GgbvTa581!@", "@Mjrc0olguy!", "007jmSB0nd!", "108turt!es762", "Avv3SoMe!305"]
all_pws = weak_pws + strong_pws
# text = codesters.Text("text", x, y, "color")
password = codesters.Text("password", 100, 200, "red")
def interval():
# add any other actions...
my_var = random.randint(1, 10)
stage.event_interval(interval, 2)
t = codesters.Teacher()
try:
tval1 = t.find_function('randint')[0][0]
tval1a = t.get_indent_at_line(tval1)
tval1b = t.find_function('randint')[0][1]
tval2 = int(t.get_parameters_for_function('randint')[0][0])
tval3 = int(t.get_parameters_for_function('randint')[0][1])
except:
tval1 = "DNE"
tval1a = "DNE"
tval1b = "DNE"
tval2 = "DNE"
tval3 = "DNE"
try:
tval4 = t.find_function('randint')[1][0]
tval4a = t.get_indent_at_line(tval4)
tval4b = t.find_function('randint')[1][1]
tval5 = int(t.get_parameters_for_function('randint')[1][0])
tval6 = int(t.get_parameters_for_function('randint')[1][1])
except:
tval4 = "DNE"
tval4a = "DNE"
tval4b = "DNE"
tval5 = "DNE"
tval6 = "DNE"
t1 = TestObjective()
t1.add_success(tval1a == 4 and tval2 == -225 and tval3 == 225 and 'rand_x'in tval1b, "Great job!")
t1.add_failure(tval1== "DNE", "Oops! Did you delete your first Random Integer command?")
t1.add_failure('rand_x' not in tval1b, "Did you change the name of your first Random Integer to rand_x?")
t1.add_failure(tval1a < 4, "Make sure your rand_x variable is indented 4 spaces inside your Interval Event.")
t1.add_failure(tval2 < -225 or tval3 > 225, "Try to keep your rand_x variable between -225 and 225.")
t1.add_failure(tval2 == 1 or tval3 == 10, "Make sure you change the parameters for your rand_x command!")
t1.add_creative(tval2 != 1 and tval2 > -225, "That's a good range for your Random Integer also!")
t1.add_creative(tval3 != 10 and tval3 < 225, "That's a good range for your Random Integer also!")
t2 = TestObjective()
t2.add_success(tval4a == 4 and tval5 == -225 and tval6 == 225 and 'rand_y'in tval4b, "Great job!")
t2.add_failure(tval4== "DNE", "Oops! Did you add a second Random Integer command?")
t2.add_failure('rand_y' not in tval4b, "Did you change the name of your second Random Integer to rand_y?")
t2.add_failure(tval4a < 4, "Make sure your rand_y variable is indented 4 spaces inside your Interval Event.")
t2.add_failure(tval5 < -225 or tval6 > 225, "Try to keep your rand_y variable between -225 and 225.")
t2.add_failure(tval5 == 1 or tval6 == 10, "Make sure you change the parameters for your rand_y command!")
t2.add_creative(tval5 != 1 and tval5 > -225, "That's a good range for your Random Integer also!")
t2.add_creative(tval6 != 10 and tval6 < 225, "That's a good range for your Random Integer also!")
tester = TestManager()
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)